問題の説明
このコードを変更して、最後の行の下の行にデータを貼り付けるにはどうすればよいですか? (How do I modify this code to paste in the row under last row with data?)
このコードをまとめたところ、データが見つかった最後の行にコピーされたセルが貼り付けられ、この下の行に貼り付ける必要があることを除いて、完全に機能します。
方法貼り付ける位置を 1 行下に移動しますか?
Sub SelectActualUsedRange()
Dim FirstCell As Range, LastCell As Range
Sheets("Set Up Current Month").Select
Set LastCell = Cells(Cells.Find(What:="*", SearchOrder:=xlRows, _
SearchDirection:=xlPrevious, LookIn:=xlValues).Row, _
Cells.Find(What:="*", SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious, LookIn:=xlValues).Column)
Set FirstCell = Cells(Cells.Find(What:="*", After:=LastCell, SearchOrder:=xlRows, _
SearchDirection:=xlNext, LookIn:=xlValues).Row, _
Cells.Find(What:="*", After:=LastCell, SearchOrder:=xlByColumns, _
SearchDirection:=xlNext, LookIn:=xlValues).Column)
Range(FirstCell, LastCell).Select
Selection.Copy
Sheets("Pasted Report").Select
If Range("A1").Value <> "" Then
Set FirstCell = Range("A1")
Else
Set FirstCell = Range("A1").End(xlDown)
End If
Set LastCell = Cells(Rows.Count, "A").End(xlUp)
LastCell.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
End Sub
リファレンスソリューション
方法 1:
I changes the bottom part of the code to ‑
Set LastCell = Cells(Rows.Count, "A").End(xlUp)
LastCell.Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
End Sub
(by Hazel Popham、Hazel Popham)